//
//  LZBoundPhoneNextViewController.m
//  DoctorFAQs
//
//  Created by langZai on 2017/2/17.
//  Copyright © 2017年 zjq. All rights reserved.
//

#import "LZBoundPhoneNextViewController.h"

@interface LZBoundPhoneNextViewController ()<UITextFieldDelegate>

/** 密码textField */
@property (nonatomic, strong) UITextField *pwdTextField;
/** 确认密码TextField */
@property (nonatomic, strong) UITextField *conTextField;
/** 上面的叉叉Btn */
@property (nonatomic, strong) UIButton *topDeleteBtn;
/** 下面的叉叉Btn */
@property (nonatomic, strong) UIButton *bottomDeleteBtn;

/** 下一步Btn */
@property (nonatomic, strong) UIButton *nextBtn;
@end

@implementation LZBoundPhoneNextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = KHColorFromRGB(0xffffff);
    self.navigationItem.title = @"设置密码";
    [self createUI];
}


- (void)createUI{
    
    // 密码
    UILabel *numLabel = [[UILabel alloc] init];
    numLabel.text = @"密码";
    numLabel.font = FONT(15);
    numLabel.textColor = KHColorFromRGB(0x333333);
    numLabel.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:numLabel];
    [numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(45 *xsIZE);
        make.top.equalTo(self.view).offset(70 *ysIZE);
    }];
    
    // 密码textField
    _pwdTextField = [[UITextField alloc] init];
    //_phoneTextField.delegate = self;
    _pwdTextField.font = NEWFONT(15);
    _pwdTextField.secureTextEntry = YES;
    _pwdTextField.delegate = self;
    _pwdTextField.textColor = KHBlackColor;
    _pwdTextField.textAlignment = NSTextAlignmentLeft;
    _pwdTextField.keyboardType = UIKeyboardTypeURL;
    [self.view addSubview:_pwdTextField];
    [_pwdTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(30*ysIZE);
        make.left.equalTo(self.view.mas_left).offset(120*xsIZE);
        make.right.equalTo(self.view).offset(-60*xsIZE);
        make.centerY.equalTo(numLabel);
    }];
    
    
    
    
    // 横线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = KHColorFromRGB(0x4bb92c);
    [self.view addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(45*xsIZE);
        make.right.equalTo(self.view).offset(-45*xsIZE);
        make.top.equalTo(self.view).offset(100 *ysIZE);
        make.height.offset(ysIZE);
    }];
    
    // 密码后面的叉叉按钮
    _topDeleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_topDeleteBtn setImage:[UIImage imageNamed:@"btn_cha"] forState:UIControlStateNormal];
    [_topDeleteBtn setTitleColor:KHGreenColor forState:UIControlStateNormal];
    _topDeleteBtn.titleLabel.font = NEWFONT(14);
    [_topDeleteBtn setBackgroundColor:KHColorFromRGB(0xffffff)];
    
    [self.view addSubview:_topDeleteBtn];
    [_topDeleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.sizeOffset(CGSizeMake(10*xsIZE, 10*ysIZE));
        make.right.equalTo(self.view.mas_right).offset(-45 *xsIZE);
        make.centerY.equalTo(_pwdTextField);
    }];
    [_topDeleteBtn addTarget:self action:@selector(pwdDeleteBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    // 确认密码
    UILabel *safeCodeLabel = [[UILabel alloc] init];
    safeCodeLabel.text = @"确认密码";
    safeCodeLabel.font = FONT(15);
    safeCodeLabel.textColor = KHColorFromRGB(0x333333);
    safeCodeLabel.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:safeCodeLabel];
    [safeCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(45 * xsIZE);
        make.top.equalTo(lineView.mas_bottom).offset(20 *ysIZE);
    }];
    
    // 确认密码textField
    _conTextField = [[UITextField alloc] init];
    _conTextField.keyboardType = UIKeyboardTypeURL;
    _conTextField.font = NEWFONT(15);
    _conTextField.secureTextEntry = YES;
    _conTextField.delegate = self;
    _conTextField.textColor = KHBlackColor;
    _conTextField.textAlignment = NSTextAlignmentLeft;
    [self.view addSubview:_conTextField];
    [_conTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.offset(30*ysIZE);
        make.right.equalTo(self.view).offset(-60*xsIZE);
        make.left.equalTo(self.view.mas_left).offset(120*xsIZE);
        make.centerY.equalTo(safeCodeLabel);
    }];
    
    
    // 下面的横线
    UIView *lineViewB = [[UIView alloc] init];
    lineViewB.backgroundColor = KHColorFromRGB(0x4bb92c);
    [self.view addSubview:lineViewB];
    [lineViewB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(45*xsIZE);
        make.right.equalTo(self.view).offset(-45*xsIZE);
        make.height.offset(ysIZE);
        make.top.equalTo(lineView.mas_bottom).offset(50 *ysIZE);
        
    }];
    
    
    // 确认密码后面的叉叉按钮
    _bottomDeleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_bottomDeleteBtn setImage:[UIImage imageNamed:@"btn_cha"] forState:UIControlStateNormal];
    [_bottomDeleteBtn setTitleColor:KHGreenColor forState:UIControlStateNormal];
    _bottomDeleteBtn.titleLabel.font = NEWFONT(14);
    [_bottomDeleteBtn setBackgroundColor:KHColorFromRGB(0xffffff)];
    [self.view addSubview:_bottomDeleteBtn];
    [_bottomDeleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.sizeOffset(CGSizeMake(10*xsIZE, 10*ysIZE));
        make.right.equalTo(self.view.mas_right).offset(-45 *xsIZE);
        make.centerY.equalTo(_conTextField);
    }];
    [_bottomDeleteBtn addTarget:self action:@selector(conPwdDeleteBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    // 完成按钮
    _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_nextBtn setTitle:@"完成" forState:UIControlStateNormal];
    [_nextBtn setBackgroundColor:KHColorFromRGB(0x7bd661)];
    _nextBtn.titleLabel.font = NEWFONT(18);
    _nextBtn.layer.cornerRadius = 5;
    [_nextBtn setTitleColor:KHColorFromRGB(0xffffff) forState:UIControlStateNormal];
    [self.view addSubview:_nextBtn];
    [_nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(45*xsIZE);
        make.right.equalTo(self.view).offset(-45*ysIZE);
        make.top.equalTo(lineViewB.mas_bottom).offset(80 *ysIZE);
        make.height.offset(35*ysIZE);
    }];
    [_nextBtn addTarget:self action:@selector(okButtonClick) forControlEvents:UIControlEventTouchUpInside];
}

// 删除密码按钮点击
- (void)pwdDeleteBtnClick {
    _pwdTextField.text = @"";
}

// 确认密码删除点击
- (void)conPwdDeleteBtnClick {
    _conTextField.text = @"";
}

// 点击下一步
- (void)okButtonClick {
    NSLog(@"完成");
}

@end
